﻿using DoNetDrive.Protocol.Door.Door8800.SystemParameter.TCPSetting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DoNetDrive.Protocol.Door.Test.TCPPublisher
{
    /// <summary>
    /// TCP消息订阅
    /// </summary>
    public abstract class TCPDetailIObserverBase : IObserver<TCPDetail>
    {
        IDisposable disposable;
        public void Subscribe(TCPDetailIObservable observable)
        {
            if (observable != null)
            {
                disposable = observable.Subscribe(this);
            }
        }
        public virtual void OnCompleted()
        {

        }

        public virtual void OnError(Exception error)
        {

        }

        public abstract void OnNext(TCPDetail value);
        /// <summary>
        /// 取消订阅
        /// </summary>
        public virtual void Unsubscribe()
        {
            disposable?.Dispose();
        }
    }
}
